import { regions } from '../../utils/regions'

Page({
  data: {
    region: ['', '', ''],
    customItem: '全部'
  },

  onChange(e) {
    this.setData({
      region: e.detail.value
    })
  },

  confirm() {
    const { region } = this.data
    if (!region[0]) {
      wx.showToast({
        title: '请选择地区',
        icon: 'none'
      })
      return
    }

    const pages = getCurrentPages()
    const prevPage = pages[pages.length - 2]
    prevPage.setData({
      'address.region': region.join(' ')
    })

    wx.navigateBack()
  }
}) 